package com.sunny.ynhz.utils;

import android.animation.ValueAnimator;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by huhuan123 on 2018/8/31.
 *
 * @describe TODO
 */

public class AnimatorUtils {
    public static void startAnimation(int startHight, int endHight, View view) {
        ValueAnimator valueAnimator = ValueAnimator.ofFloat(startHight, endHight);
        valueAnimator.setTarget(view);
        valueAnimator.setDuration(startHight > endHight ? startHight : endHight);
        valueAnimator.addUpdateListener(valueAnimator1 -> {
            float parseFloat = Float.parseFloat(valueAnimator1.getAnimatedValue().toString());
            ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
            layoutParams.height = (int) parseFloat;
            view.requestLayout();
        });
        valueAnimator.start();
    }
}
